import request from '@/config/axios'

export interface AlertVO {
  id: number
  deviceId: string
  deviceName?: string
  alertType: string
  alertValue: number
  threshold: number
  alertTime: Date
  message?: string
  status?: string
  createTime: Date
}

export interface AlertPageReqVO extends PageParam {
  deviceId?: string
  alertType?: string
  alertValue?: number
  threshold?: number
  alertTime?: Date[]
  message?: string
  status?: string
  createTime?: Date[]
}

export interface AlertExportReqVO {
  deviceId?: string
  alertType?: string
  alertValue?: number
  threshold?: number
  alertTime?: Date[]
  message?: string
  status?: string
  createTime?: Date[]
}

// 创建能耗预警
export const createAlert = (data: AlertVO) => {
  return request.post({ url: '/energy/alert/create', data })
}

// 更新能耗预警
export const updateAlert = (data: AlertVO) => {
  return request.put({ url: '/energy/alert/update', data })
}

// 删除能耗预警
export const deleteAlert = (id: number) => {
  return request.delete({ url: '/energy/alert/delete?id=' + id })
}

// 获得能耗预警
export const getAlert = (id: number) => {
  return request.get({ url: '/energy/alert/get?id=' + id })
}

// 获得能耗预警分页
export const getAlertPage = (params: AlertPageReqVO) => {
  return request.get({ url: '/energy/alert/page', params })
}

// 导出能耗预警 Excel
export const exportAlert = (params: AlertExportReqVO) => {
  return request.download({
    url: '/energy/alert/export-excel',
    params
  })
}
// API接口命名空间
export const AlertApi = {
  createAlert,
  updateAlert,
  deleteAlert,
  getAlert,
  getAlertPage,
  exportAlert
}
